package com.hc.comm.filter;


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.hc.comm.utils.ServletUtil;



/**
 * 用户会话filter，用于初始化session的一些操作
 * 
 * @author 
 * 
 */
public class SessionFilter implements Filter {

	private Logger logger = Logger.getLogger(SessionFilter.class);

	@Override
	public void destroy() {

	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		logger.debug(this + " sessionFilter");
		sessionInit((HttpServletRequest) request,
				(HttpServletResponse) response);
		chain.doFilter(request, response);
	}

	public void sessionInit(HttpServletRequest request,
			HttpServletResponse response) {
		ServletUtil.initSessionId(request, response);
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {

	}

}
